package com.longteng.java.web.dataproducer;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by tianqing.wang
 * DATE : 2018/3/18
 * TIME : 上午12:02
 * PROJECT : java-lesssion
 * PACKAGE : com.gitee.longteng.lession.lesson2.dataproducer
 *
 * @author <a href="mailto:celeskyking@163.com">tianqing.wang</a>
 */
public class OrderDataGenerator implements DataGenerator<String>{



    private AtomicInteger atomicInteger = new AtomicInteger();


    private static final String BASE = "01234567890";



    @Override
    public String generate() {
        String number  = String.valueOf(atomicInteger.getAndIncrement());
        return number+System.currentTimeMillis()+getNumber(17-number.length());
    }


    private String getNumber(Integer size){
        StringBuilder stringBuilder = new StringBuilder();
        for(int i=0;i<size;i++){
            stringBuilder.append(BASE.toCharArray()[RandomUtil.getRandom(0,BASE.length()-1)]);
        }
        return stringBuilder.toString();
    }


}
